package com.xbongbong.paas.model.impl;

import com.xbongbong.paas.model.CustomButtonModel;
import com.xbongbong.paas.toolbox.exception.XbbException;
import com.xbongbong.paas.toolbox.util.DateTimeUtil;
import com.xbongbong.pro.domain.dao.CustomButtonDao;
import com.xbongbong.pro.domain.entity.CustomButtonEntity;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @author 吴峰
 * @date 2021/03/03 16:28
 */
@Service("customButtonModel")
public class CustomButtonModelImpl implements CustomButtonModel {
    @Resource
    private CustomButtonDao customButtonDao;

    @Override
    public Integer insert(CustomButtonEntity entity) throws XbbException {
        Long now = DateTimeUtil.getInt();
        entity.setAddTime(now);
        entity.setUpdateTime(now);
        return customButtonDao.insert(entity);
    }

    @Override
    public Integer update(CustomButtonEntity entity) throws XbbException {
        Long now = DateTimeUtil.getInt();
        entity.setUpdateTime(now);
        return customButtonDao.update(entity);
    }

    @Override
    public List<CustomButtonEntity> findEntitys(Map<String, Object> param) {
        return customButtonDao.findEntitys(param);
    }

    @Override
    public Integer getEntitysCount(Map<String, Object> param) {
        return customButtonDao.getEntitysCount(param);
    }

    @Override
    public List findEntitysWithoutSub(Map<String, Object> param) {
        return null;
    }

    @Override
    public Integer insertBatch(List<CustomButtonEntity> addList) {
        return customButtonDao.insertBatch(addList);
    }

    @Override
    public Integer deleteBatch(List<Long> list, String corpid) {
        return customButtonDao.deleteBatch(list, corpid);
    }

    @Override
    public Integer updateBatch(List<CustomButtonEntity> updateList,  String corpid) {
        return customButtonDao.updateBatch(updateList, corpid);
    }

    @Override
    public Integer deleteByFormId(Long formId, String corpid, Integer businessType) {
        return customButtonDao.deleteByFormId(formId, corpid, businessType);
    }
}
